﻿/********************************************************************************************************************
* Author:	Aris Michail																							*
* Email:	std03055@di.uoa.gr																						*
* Purpose:	This script is used in order to create the stored procedure "usp_getCategory" that returns a			*
*			category.																								*
********************************************************************************************************************/

CREATE PROCEDURE [dbo].[usp_getCategory]
	@categoryid bigint

AS
	DECLARE @entitiescount int

	SELECT @entitiescount = COUNT(*)
	FROM Entities
	WHERE Entities.Category = @categoryid

	SELECT id,name,isprivate,datecreated,Owner,IsApproved,@entitiescount as entitycount
	FROM Categories
	WHERE Categories.ID = @categoryid

RETURN 0